package com.pen.sample.client.model;

import java.util.ArrayList;

import com.google.gwt.core.client.GWT;
import com.pen.sample.client.model.delegate.IDelegate;
import com.pen.sample.client.model.delegate.IResponder;

public class TradeRoutes implements ITradeRoutes
{
	private final static String SERVER_URL = GWT.getHostPageBaseURL() + "/stockPrices.php?";
	
	private IDelegate _delegate;
	
	public TradeRoutes( IDelegate delegate )
	{
		_delegate = delegate;
	}

	@Override
	public void getStocks( ArrayList<String> symbols, IResponder callback )
	{
		String url = SERVER_URL;
		for ( int i = 0; i < symbols.size(); i++ )
			url += symbols.get( i ) + "+";
		url = url.substring( 0, url.length()-1 );
		_delegate.get( url , callback );
	}
	
	public void kill()
	{
		_delegate = null;
	}
}
